package base

/*
* @author: hjz
* @time: 2025/4/26 22:22
* @ 计算顺序要记住只能
 */
func maxSubArray(nums []int) int {
	tmp := nums[0]
	res := tmp
	for i := 1; i < len(nums); i++ {
		if tmp > 0 {
			tmp += nums[i]
		} else {
			tmp = nums[i]
		}
		res = maxInt(res, tmp)
	}
	return maxInt(res, tmp)
}
